package com.jsb.gatewayservice;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//@RequestMapping(".well-known")
public class GatewayController {
    @RequestMapping("apple-app-site-association")
    public ResponseEntity<Resource> iosDl() {
        String fileName = "apple-app-site-association";  // 文件名，包括扩展名
        String filePath = "ios/" + fileName;  // 文件路径，相对于resources目录下的ios文件夹

        Resource resource = new ClassPathResource(filePath);

        HttpHeaders headers = new HttpHeaders();
        headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileName);

        return ResponseEntity
                .ok()
                .headers(headers)
                .contentType(MediaType.APPLICATION_OCTET_STREAM)
                .body(resource);
    }
}
